<template>
  <div>
    <!-- <div class="top_hytitle">
      <div class="letf_line"></div>
      <div class="center_text">欢迎回来</div>
      <div class="right_line"></div>
    </div> -->
    <div class="">
      <p style="margin: 15px 0; color: #9998a9">
        {{ formatTimestamp(topList.createTime) }}
      </p>

      <div class="top-box" :class="isShadow?'boxShadow':''">
        <img src="../../assets/iconIndex/solei_logo.png" class="solei_logo" alt="">
        <!-- <p>{{ topList.title }}</p> -->
        <div class="top-box-list top-box-list-link" style="background: linear-gradient(180deg, rgba(231,46,46,0.07) 0%, rgba(231,46,46,0.03) 100%);border: 1px solid rgba(231,46,46,0.1);padding-bottom: 17px;">
          <div v-for="(topItemCard, topItemIndex) in topList.card" class="top-box-list-item" :key="topItemIndex" :style="{
            marginBottom:
              topItemIndex === topList.card.length - 1 ? '0px' : '30px',
          }" @click="gotosldetails(topItemCard)">
            <p>
              <img src="../../assets/images/gt_icon.png" class="topboximgs" alt="" />
              <strong>{{ topItemCard.name.split("（")[0] }}</strong>{{
                topItemCard.name.split("（")[1]
                  ? "（" + topItemCard.name.split("（")[1]
                  : ""
              }}
            </p>
            <p class="top-box-list-item-red">{{ topItemCard.sub }}</p>
          </div>
        </div>
        <div class="top-box-btn" @click="djseegdfxnews">
          点击查看更多自选风险信息
        </div>
        <p class="askMe">你可以尝试这样问我</p>
        <div @click="sendMessageBy(topItemLink)" v-for="(topItemLink, topItemLinkIndex) in topList.link"
          class="top-box-list-item-link" :key="topItemLinkIndex">
          {{ topItemLink }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { } from "@/utils/common";
import { Toast } from "vant";
import commonFunc from "@/utils/ysjh";
export default {
  data() {
    return {
    };
  },
  props: {
    topList: {
      type: Object,
      default: () => { },
    },isShadow: {
    type: Boolean,
    default: false,
  },

  },
  watch: {},
  mounted() { },
  created() { },
  methods: {
    //去排雷查看详情
    gotosldetails(item) {
      console.log(item, "itme");
      let openSource = item.url.openSource;
      let openType = item.url.openType;
      let functionCode = item.url.functionCode;
      let param = item.url.param;
      commonFunc.openService(openSource, openType, functionCode, param);
      // const leftBracketIndex = item.name.indexOf("（");
      // const rightBracketIndex = item.name.indexOf("）");
      // if (leftBracketIndex !== -1 && rightBracketIndex !== -1) {
      //   const stockName = item.name.substring(0, leftBracketIndex);
      //   const stockCode = item.name.substring(
      //     leftBracketIndex + 1,
      //     rightBracketIndex
      //   );
      //   console.log(stockName, stockCode);
      //   stockCode.toString();
      //   let code = "";
      //   if (stockCode.substr(0, 2) == "68") {
      //     code = "0107" + stockCode;
      //   } else if (stockCode.substr(0, 1) == "6") {
      //     code = "0101" + stockCode;
      //   } else if (
      //     stockCode.substr(0, 1) == "0" ||
      //     stockCode.substr(0, 1) == "3"
      //   ) {
      //     code = "0001" + stockCode;
      //   } else if (
      //     stockCode.substr(0, 1) == "4" ||
      //     stockCode.substr(0, 1) == "8"
      //   ) {
      //     code = "0401" + stockCode;
      //   } else if (stockCode.substr(0, 1) == "5") {
      //     code = "0103" + stockCode;
      //   } else if (stockCode.substr(0, 1) == "1") {
      //     code = "0003" + stockCode;
      //   }
      //   console.log(code, "codecodecode");
      //   console.log(stockName, "stockName");

      //   const JumpUrl =
      //     "http://guoyuan4.dengtacj.cn:55561/MineScanner/index.html#/pages/mineDimension/mineDimension?stockCode=" +
      //     code +
      //     "&stockName=" +
      //     stockName;
      //   commonFunc.openService("", "4", "KDS_WebPageWithHead", {
      //     webUrl: JumpUrl,
      //     loginType: "1",
      //   });
      // }
    },
    //去日报查看详情
    gotozxrbdetails(item) {
      console.log(item.name, "item,item");
      const leftBracketIndex = item.name.indexOf("（");
      const rightBracketIndex = item.name.indexOf("）");
      if (leftBracketIndex !== -1 && rightBracketIndex !== -1) {
        const stockName = item.name.substring(0, leftBracketIndex);
        const stockCode = item.name.substring(
          leftBracketIndex + 1,
          rightBracketIndex
        );
        commonFunc.openService("", "3", "FN_Native_HangQing_StockDetail", {
          dzhStockCode: stockCode,
          dzhStockType: "1",
          stockName: stockName,
        });
      }
    },
    //点击日报查看更多机会
    djrbseechance() {
      const JumpUrl = "GYDJL://kds519/view/zxrb/home/zxrb.html";
      console.log(JumpUrl, "JumpUrlJumpUrl");
      const params = {
        jsCommands_onLoad: ["setTableIndex(0)"],
      };
      commonFunc.openService("", "4", "KDS_WebPageNoHead", {
        webUrl: JumpUrl,
        loginType: "1",
        params: params,
      });
    },
    //点击查看更多自选风险信息
    djseegdfxnews() {
      let openSource = this.topList.url.openSource;
      let openType = this.topList.url.openType;
      let functionCode = this.topList.url.functionCode;
      let param = this.topList.url.param;
      commonFunc.openService(openSource, openType, functionCode, param);
    },
    sendMessageBy(e) {
      this.$parent.showCollect = false
      this.$parent.someMethod(e)

    },
    formatTimestamp(ms) {
      if (!ms) {
        return "";
      }
      const time = Number(ms);
      if (!time || isNaN(time)) return "-";
      const d = new Date(time);
      const Y = d.getFullYear();
      const M = String(d.getMonth() + 1).padStart(2, "0");
      const D = String(d.getDate()).padStart(2, "0");
      const h = String(d.getHours()).padStart(2, "0");
      const m = String(d.getMinutes()).padStart(2, "0");
      const s = String(d.getSeconds()).padStart(2, "0");
      return `${Y}-${M}-${D} ${h}:${m}:${s}`;
    },

  },
};
</script>

<style lang="less" scoped>
.solei_logo{
  width: 208px;
  height: 23px;
}
</style>